<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      // 组合式继承
      function Father(uname, age) {
        this.uname = uname
        this.age = age
        // console.log(this);
      }
      Father.prototype.money = function () {
        console.log('我赚了一个小目标')
      }

      function Son(uname, age) {
        Father.call(this, uname, age)
      }
      // // 把Father的实例化对象给Son
      // Son.prototype = new Father()
      // // 将Son.prototype的constructor属性指回Son构造函数
      // Son.prototype.constructor = Son

      // 把Father的原型对象给Son的原型对象的__proto__
      Son.prototype.__proto__ = Father.prototype
      // 给Son添加新属性
      Son.prototype.dance = function () {
        console.log('跳舞')
      }
      const father = new Father('zs', 40)
      const son = new Son('ls', 18)
      // console.log(uname);
      console.log(son)
      son.money()
      son.dance()
      father.dance()
    </script>
  </body>
</html>
